package com.rop.znyx.common.auth;

import com.rop.znyx.vo.user.UserLoginVo;

/**
 * Created with IntelliJ IDEA
 * User: Rop
 * Date: 2023/7/19
 * Time: 10:51
 * Description: ThreadLocal工具类
 */
public class AuthContextHolder {

    // 用户id
    private static ThreadLocal<Long> userId = new ThreadLocal<>();

    // 用户仓库id
    private static ThreadLocal<Long> wareId = new ThreadLocal<>();

    // 用户信息对象
    private static ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    // userId操作的方法
    public static void setUserId(Long id) {
        userId.set(id);
    }

    public static Long getUserId() {
        return userId.get();
    }

    // wareId操作的方法
    public static void setWareId(Long id) {
        wareId.set(id);
    }

    public static Long getWareId() {
        return wareId.get();
    }

    // userLoginVo操作的方法
    public static void setUserLoginVo(UserLoginVo vo) {
        userLoginVo.set(vo);
    }

    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }

}
